<?php
    require_once './Class/GetGpw.php';
    require_once './Class/GetYahoo.php';

    

    
    $name = '';
    if(isset($_POST) && count($_POST)>0)
    {
        $config = $_POST;
        $config['instrumentType'] = 10;
       
        if($_GET['type'] == 'gpw')
        {
            $get = new GetGPW($config);
            $get->cutFromPost($_POST);
        } else if($_GET['type'] == 'yahoo')
        {
            $get = new GetYahoo($config);
            $get->cutFromPost($_POST);
        }

        //$get->removeHeader();
        $name = $get->saveCsv();
        //exec( 'aaa.exe '.$name.' a', $output);
        //var_dump($output);
        
    }
    
    
    
    
    
    

?>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
        <link rel="stylesheet" href="/resources/demos/style.css">
        <script>
            $(function() {
              $( ".datepicker" ).datepicker({
                dateFormat: "yy-mm-dd"
              });
            });
        </script>
    </head>
    <body>
        
        <?php
            echo '<a href="'.$name.'">'.$name.'</a>';
        ?>
           
        <h1>GPW</h1>
        <form action="index.php?type=gpw" method="POST">
            Date: <input type="text" name="dateFrom" class="datepicker"> - <input type="text" name="dateTo" class="datepicker">
            <select name="isin">
                <option value="PLZYWIC00016">Żywiec</option>
                <option value="PLPEKAO00016">PEKAO</option>
                <option value="PLK2ITR00010">K2INTERNT</option>
                <option value="PLKRCHM00015">Alma</option>
            </select>
            <br>
            
            <label for="date">Date</label> <input type="checkbox"  name="date" >
            <label for="openPrice">Open price</label><input type="checkbox"  name="openPrice" >
            <label for="lowPrice">Low price</label><input type="checkbox"  name="lowPrice" >
            <label for="closePrice">Close price</label><input type="checkbox"  name="closePrice" >
            <label for="change">Change</label><input type="checkbox"  name="change" >
            <label for="volume">Volume</label><input type="checkbox"  name="volume" >
            <label for="transactionNumber">transactionNumbers</label><input type="checkbox"  name="transactionNumber" >
            <label for="value">Value</label><input type="checkbox"  name="value" >
            
            <input type="submit" value="Pobierz">

            
            
            
        </form>
        
        <h1>Yahoo</h1>
        <form action="index.php?type=yahoo" method="POST">
            Date: <input type="text" name="dateFrom" class="datepicker"> - <input type="text" name="dateTo" class="datepicker">
            <select name="isin">
                <option value="ACN">ACN</option>
                <option value="BP">BP</option>
                <option value="FB">Facebook</option>
            </select>
            <br>
             <label for="date">Date</label> <input type="checkbox"  name="date" >
            <label for="openPrice">Open price</label><input type="checkbox"  name="openPrice" >
            <label for="lowPrice">Low price</label><input type="checkbox"  name="lowPrice" >
            <label for="closePrice">Close price</label><input type="checkbox"  name="closePrice" >
            <label for="volume">Volume</label><input type="checkbox"  name="volume" >
            
            
       
            <input type="submit" value="Pobierz">
        </form>
        
    </body>
</html>
